package com.example.user_registration.service;

import com.example.user_registration.model.User;
import com.example.user_registration.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;

    public boolean registerUser(User user) {
        // 检查邮箱是否已注册
        if (userRepository.findByEmail(user.getEmail()) != null) {
            return false; // 邮箱已注册
        }
        // 保存用户
        userRepository.save(user);
        return true; // 注册成功
    }
}